# PHP 5 SimpleXML Functions

« Previous
Next Chapter »

## PHP SimpleXML Introduction

SimpleXML is an extension that allows us to easily manipulate and get XML data.

SimpleXML provides an easy way of getting an element's name, attributes and textual content if you know the XML document's structure or layout.

SimpleXML turns an XML document into a data structure you can iterate through like a collection of arrays and objects.

## Installation

As of PHP 5, the SimpleXML functions are part of the PHP core. No installation is required to use these functions.

## PHP 5 SimpleXML Functions

Function | Description
--- | ---
__construct() | Creates a new SimpleXMLElement object
addAttribute() | Adds an attribute to the SimpleXML element
addChild() | Adds a child element the SimpleXML element
asXML() | Returns a well-formed XML string (XML version 1.0) from a SimpleXML object
attributes() | Returns the attributes/values of an element
children() | Returns the children of a specified node
count() | Counts the children of a specified node
getDocNamespaces() | Returns the namespaces DECLARED in document
getName() | Returns the name of the XML tag referenced by the SimpleXML element
getNamespaces() | Returns the namespaces USED in document
registerXPathNamespace() | Creates a namespace context for the next XPath query
saveXML() | Alias of asXML()
simplexml_import_dom() | Returns a SimpleXMLElement object from a DOM node
simplexml_load_file() | Converts an XML file into a SimpleXMLElement object
simplexml_load_string() | Converts an XML string into a SimpleXMLElement object
xpath() | Runs an XPath query on XML data

## PHP 5 SimpleXML Iteration Functions

Function | Description
--- | ---
current() | Returns the current element
getChildren() | Returns the child elements of the current element
hasChildren() | Checks whether the current element has children
key() | Return the current key
next() | Moves to the next element
rewind() | Rewind to the first element
valid() | Check whether the current element is valid

« Previous
Next Chapter »

### WEB HOSTING

UK Reseller Hosting

### WEB BUILDING

FREE Website BUILDER Free HTML5 Templates

### W3SCHOOLS EXAMS

HTML, CSS, JavaScript, PHP, jQuery, XML, and ASP Certifications

### SHARE THIS PAGE

### Color Picker

### HTML/CSS

HTML Tutorial HTML5 Tutorial CSS Tutorial CSS3 Tutorial Bootstrap Tutorial

### JavaScript

JavaScript Tutorial jQuery Tutorial jQuery Mobile Tutorial AngularJS Tutorial AJAX Tutorial JSON Tutorial

### Graphics

Canvas Tutorial SVG Tutorial Google Maps Tutorial

### Server Side

SQL Tutorial PHP Tutorial ASP Tutorial ASP.NET Tutorial VBScript Tutorial AppML Tutorial

### Web

Web Building Web Statistics Web Certification

### XML

XML Tutorial DTD Tutorial Schema Tutorial XML DOM Tutorial XPath Tutorial XSLT Tutorial XQuery Tutorial XSL-FO Tutorial RSS Tutorial WSDL Tutorial

### HTML/CSS

HTML Tag Reference HTML Event Reference HTML Color Reference CSS 1,2,3 Reference Bootstrap Reference

### JavaScript

JavaScript Reference HTML DOM Reference jQuery Reference jQuery Mobile Reference Google Maps Reference

### Server Side

PHP Reference SQL Reference ASP Reference VBScript Reference Razor Reference ASP.NET Reference

### XML

XML DOM Reference XSLT Reference XSL-FO Reference XPath Reference XQuery Reference Schema Reference RSS Reference SVG Reference

### HTML Charsets

HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8

### HTML/CSS

HTML Examples CSS Examples

### Browser Scripting

JavaScript Examples HTML DOM Examples jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples

### Server Scripting

PHP Examples ASP Examples VBScript Examples Razor Examples .NET Examples

### XML Languages

XML Examples DTD Examples XML DOM Examples XSL Examples XSLT Examples XPath Examples XQuery Examples Schema Examples RSS Examples SVG Examples